package org.example.io.ex7;

import java.io.*;
import java.util.Scanner;

public class MPrint {
    public static void main(String[] args) {
//        printStream();
        printWriter();
    }

    public static void printStream() {
        try (PrintStream p = new PrintStream(System.out)){
            Scanner scanner = new Scanner(System.in);
            p.write(10);
            p.write('\n');
            p.write("asd".getBytes());
            p.println("println|");
            p.print("print|");
            p.format("format|");

            scanner.nextLine(); // 阻塞
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void printWriter() {
        try (PrintWriter p = new PrintWriter(System.out, true)){
            Scanner scanner = new Scanner(System.in);
            while (true){
                String s = scanner.nextLine();
                p.println("println:" + s);
                p.print("print:" + s + "|");
                p.format("format:%s|", s);
                p.write("write:" + s + "|");
                if ("baibai".equals(s))
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
